﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data.SqlClient;

public partial class admin_pathneedtobedeletedclear : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string mPath="",path="";
        OleDbConnection Conn = new OleDbConnection();
        Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("../miumiu.mdb");
        Conn.Open();
        string sql = "select pathneedtobedeleted from pathneedtobedeleted";
        OleDbCommand myCommand = new OleDbCommand(sql, Conn);
        myCommand.ExecuteNonQuery();
        OleDbDataReader dr = myCommand.ExecuteReader();
        while (dr.Read())
        {
            path = Convert.ToString(dr["pathneedtobedeleted"]);
            //sql = "delete from pathneedtobedeleted where pathneedtobedeleted= '" + path + "'";
            mPath = Server.MapPath(path);
            if (Directory.Exists(mPath))
            {
                Directory.Delete(mPath);
                Response.Write("<script language=javascript>alert('已成功删除一条！');</script>");
            }
            sql = "delete from pathneedtobedeleted where pathneedtobedeleted= '" + path + "'";
            OleDbCommand scd = new OleDbCommand(sql, Conn);
            scd.ExecuteNonQuery();
        }

        Conn.Close();
        Response.Write("<script language=javascript>alert('操作成功');window.parent.main.location.href = 'pathneedtobedeletedclear.aspx';</script>");

    }

}
